<%--
  Created by IntelliJ IDEA.
  User: sxjzit001
  Date: 2023/5/12
  Time: 10:44
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <script src="https://cdn.bootcdn.net/ajax/libs/axios/1.3.6/axios.js"></script>
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.4/jquery.js"></script>
    <title>$Title$</title>
    <script>
        $(function () {
            $(".submit").click(function () {
                <%--      使用 post 方式给服务器提交 json 格式的数据--%>
                axios.post('http://localhost:8080/AjaxJson/JsonServlet',
                    {name: "lisi", psd: "111", user: '123'}
                )
                    .then(function (response) {
                        // handle success
                        console.log("axios success", response);
                    })
            })

            $(".submit2").click(function () {
                <%--      使用 post 方式给服务器提交 json 格式的数据--%>
                axios.post('http://localhost:8080/AjaxJson/JsonServlet',
                    "name=123"
                )
                    .then(function (response) {
                        // handle success
                        console.log("axios success", response);
                    })
            })
        })
    </script>
</head>
<body>
<button class="submit">post提交json数据</button>
<button class="submit2">post提交表单数据</button>
</body>
</html>
